package project.bank.views;

import java.awt.BorderLayout;

import javax.swing.UIManager;

import project.bank.framwork.BaseForm;

import com.finco.account.IAccount;
import com.finco.account.IEntry;

/**
 * A basic JFC based application.
 */
public class BankFrm extends BaseForm implements IObserver
{

	public BankFrm()
	{
		SymAction lSymAction = new SymAction();
		JButton_PerAC = new BtnAddPerson(this,lSymAction);
		JButton_PerAC.setText("Add personal account");
		JButton_PerAC.setActionCommand("AddPerson");
		JButton_PerAC.setBounds(24,20,192,33);
		addComponent(JButton_PerAC);

		JButton_CompAC = new BtnAddCompany(this,lSymAction);
		JButton_CompAC.setText("Add company account");
		JButton_CompAC.setActionCommand("AddCompany");
		JButton_CompAC.setBounds(240,20,192,33);
		addComponent(JButton_CompAC);


		JButton_Withdraw = new BtnWithdraw(this,lSymAction);
		JButton_Withdraw.setBounds(468,164,96,33);
		JButton_Withdraw.setText("Withdraw");
		addComponent(JButton_Withdraw);

		JButton_Addinterest = new BtnAddInterest(this,lSymAction);
		JButton_Addinterest.setBounds(448,20,106,33);
		JButton_Addinterest.setText("Add interest");
		addComponent(JButton_Addinterest);


		BtnDeposit btnDeposit = new BtnDeposit(this,lSymAction);
		btnDeposit.setText("Deposit");
		btnDeposit.setBounds(468,104,96,33);
		addComponent(btnDeposit);

		setTitle("Bank1 Application.");
		setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout(0,0));
		setSize(575,310);
		setVisible(false);
		JPanel1.setLayout(null);
		getContentPane().add(BorderLayout.CENTER, JPanel1);
		JPanel1.setBounds(0,0,575,310);

		String[] columns ={"AccountNr","Name","City","P/C","Ch/S","Amount"};
	    addTableColumns(columns);
	}

	static public void main(String args[])
	{
		try {

		    try {
		        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		    }
		    catch (Exception e) {
		    }

			//Create a new instance of our application's frame, and make it visible.
			(new BankFrm()).setVisible(true);
		}
		catch (Throwable t) {
			t.printStackTrace();
			//Ensure the application exits with an error condition.
			System.exit(1);
		}
	}


	javax.swing.JPanel JPanel1 = new javax.swing.JPanel();
	javax.swing.JButton JButton_PerAC;
	BtnAddCompany JButton_CompAC;
	javax.swing.JButton JButton_Deposit;
	javax.swing.JButton JButton_Withdraw;
	javax.swing.JButton JButton_Addinterest;
	javax.swing.JButton JButton_Exit;

	class SymAction implements java.awt.event.ActionListener
	{
		public void actionPerformed(java.awt.event.ActionEvent event)
		{
			ICommandBtn object = (ICommandBtn) event.getSource();
			object.execute();
		}
	}

	@Override
	public void notifyAddAccount(IAccount account) {
		System.out.print("Account added");
		//DefaultTableModel model = (DefaultTableModel) JTable1.getModel();
		//model.addRow(new Object[]{"name","acc","324","","","34"});
	}


	@Override
	public void update(IEntry entry) {
		System.out.print("Account updated");
		//DefaultTableModel model = (DefaultTableModel) JTable1.getModel();
		//model.setValueAt(4, 0, 5);
	}
}
